Skip to content

[textual_inversion_sdxl.py] fix lr scheduler steps count#11557

Merged
linoytsaban merged 3 commits into
huggingface:mainfrom
yuanjua:fix_lr_scheduler_textual_inversion_sdxl
May 29, 2025
Merged

[textual_inversion_sdxl.py] fix lr scheduler steps count#11557
linoytsaban merged 3 commits into
huggingface:mainfrom
yuanjua:fix_lr_scheduler_textual_inversion_sdxl

Conversation

@yuanjua

@yuanjua yuanjua commented May 15, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Part of #8384
Fix for LR in a distributed training when num_train_epoch is passed

run with the following scripts:

from huggingface_hub import snapshot_download

local_dir = "./cat"
snapshot_download(
    "diffusers/cat_toy_example", local_dir=local_dir, repo_type="dataset", ignore_patterns=".gitattributes"
)
#!/bin/bash

mkdir -p textual_inversion_cat/logs

accelerate launch \
  --multi_gpu \
  --num_processes=2 \
  --mixed_precision="bf16" \
  textual_inversion_sdxl.py \
  --pretrained_model_name_or_path="stabilityai/stable-diffusion-xl-base-1.0" \
  --train_data_dir="./cat" \
  --output_dir="textual_inversion_cat" \
  --placeholder_token="<my-token>" \
  --initializer_token="cat" \
  --resolution=1024 \
  --train_batch_size=1 \
  --gradient_accumulation_steps=1 \
  --max_train_steps=100 \
  --learning_rate=1e-4 \
  --num_vectors=4 \
  --validation_prompt="a photo of a <my-token>" \
  --num_validation_images=4 \
  --validation_steps=100 \
  --save_steps=500 \
  --mixed_precision="bf16" \
  --enable_xformers_memory_efficient_attention \
  --gradient_checkpointing \
  --center_crop \
  --report_to="tensorboard" \
  --logging_dir="textual_inversion_cat/logs"

Before submitting

Who can review?

@sayakpaul

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@linoytsaban linoytsaban merged commit 89ddb6c into huggingface:main May 29, 2025
9 checks passed
@DN6 DN6 added the roadmap Add to current release roadmap label Jun 5, 2025
@DN6 DN6 moved this from In Progress to Done in Diffusers Roadmap 0.39 Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

roadmap Add to current release roadmap

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants